package dao

import (
	"cms/model"
	"github.com/wdaglb/korm"
)

// GetBoardList 获取栏目列表
func GetBoardList(list *[]model.Board) error {
	db := korm.NewContext()
	return db.Model(&list).OrderByAsc("Sort").Select().Error
}

// GetBoardInfo 获取栏目信息
func GetBoardInfo(id int, data *model.Board) error {
	db := korm.NewContext()
	return db.Model(&data).Where("Id", id).Find().Error
}

// CreateBoard 创建栏目
func CreateBoard(board *model.Board) error {
	db := korm.NewContext()
	return db.Model(&board).Create()
}

// UpdateBoard 修改栏目信息
func UpdateBoard(board *model.Board) error {
	db := korm.NewContext()
	return db.Model(&board).Where("Id", board.Id).Update()
}

// DeleteBoard 删除栏目
func DeleteBoard(board *model.Board) error {
	db := korm.NewContext()
	return db.Model(&board).Where("Id", board.Id).Delete()
}
